package com.lethelh.reflect;

import com.lethelh.reflect.entity.Cat;
import com.lethelh.reflect.entity.Dog;

/**
 * 反射:动物测试类
 */
public class AnimalSample {
    public static void main(String[] args) {
        try {

            Class catClass = Class.forName("com.lethelh.reflect.entity.Cat");
            Class dogClass = Class.forName("com.lethelh.reflect.entity.Dog");

            Cat cat = (Cat)catClass.newInstance();
            Dog dog = (Dog)dogClass.newInstance();

            System.out.println(cat);
            System.out.println(dog);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
